package com.meritit.config.javapoet;

import java.io.IOException;

import javax.lang.model.element.Modifier;

import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeSpec;

public class Test1 {

	public static void main(String[] args) throws IOException {
		MethodSpec method = MethodSpec.methodBuilder("main")
				.addModifiers(Modifier.STATIC, Modifier.PUBLIC)
				.returns(void.class)
				.addParameter(String[].class, "args")
				.addCode("$T.out.println($S)", System.class, "Hello World!")
				.build();
		
		TypeSpec helloWorld = TypeSpec.classBuilder("HelloWorld")
				.addModifiers(Modifier.FINAL, Modifier.PUBLIC)
				.addMethod(method)
				.build();
		
		JavaFile javaFile = JavaFile.builder("com.meritit.javapoet", helloWorld).build();
		
		javaFile.writeTo(System.out);
				
	}
	
}
